my combo box id is combo1, i want to clear the values that are loaded in combo box from database, plz help me with sample code..
7 27553 b1randon 171
Recognized Expert New Member
my combo box id is combo1, i want to clear the values that are loaded in combo box from database, plz help me with sample code..
Post some code that we can help you with...
//my coding...
var strDetails;
var intLoop;
var strArrRow = new Array();
strDetails=xmlHttp.statusText;//records to load combo..
strArrRow =strDetails.split('|');
var x=document.getElementById("combo1");
for (intLoop=0;intLoop<strArrRow.length-1;intLoop++)
{
var y=document.createElement('option');
y.text=strArrRow[intLoop]
try
{
x.add(y, null);
}
catch(ex)
{
x.add(y);
}
}
//my coding...
var strDetails;
var intLoop;
var strArrRow = new Array();
strDetails=xmlHttp.statusText;//records to load combo..
strArrRow =strDetails.split('|');
var x=document.getElementById("combo1");
for (intLoop=0;intLoop<strArrRow.length-1;intLoop++)
{
var y=document.createElement('option');
y.text=strArrRow[intLoop]
try
{
x.add(y, null);
}
catch(ex)
{
x.add(y);
}
}
I'm a bit confused here. Do you want to delete values from the database or do you want to clear options from a select box?
sorry to make u confused sir, i want to clear the options from the select box. not from database.
sorry to make u confused sir, i want to clear the options from the select box. not from database.
Well the general rule is if you have a select by the name box, then
To clear all options of box just do
box.options.length = 0;
b1randon 171
Recognized Expert New Member
Well the general rule is if you have a select by the name box, then
To clear all options of box just do
box.options.length = 0;
This is by far the best way to remove the options. If you try to remove them one by one in a loop you won't be able to remove the last option. I lost a good bit of hair before realizing that options.length=0; is all I needed :/
This is by far the best way to remove the options. If you try to remove them one by one in a loop you won't be able to remove the last option. I lost a good bit of hair before realizing that options.length=0; is all I needed :/
I hope the hair grew back on.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mr_burns |
last post by:
hi,
using javascript, how do i select an option in a combo box? i have
tried looking on the internet but dont really know what i should be
searching for. what i want to happen is that when a...
|
by: Stephen Miller |
last post by:
I have a page with many, dynamically generated combo boxes and I want
to check all of them, before I add a unique value to specific combo.
What would be the best way to work through the document...
|
by: SAN CAZIANO |
last post by:
how can clear an html SELECT and next insert in it all the elements of an array ()
I try this but seems doesn't works.
function ComboAddArrayValueWithLabel(combo,ArrayLabel,ArrayValue)
{ ...
|
by: Harry Haller |
last post by:
<select name="cboPlaces" id="cboPlaces">
<option value="3">Countryside</option>
<option value="4">Forest</option>
<option value="5">Mountain</option>
<option value="6">Desert</option>
<option...
|
by: Eric Layman |
last post by:
Hi,
I have a radio button and a combo box.
Upon changing a value for radio button, the combo box values will be
dynamically updated.
I have an idea on how to go abt doing it but Im stuck...
|
by: buss123 |
last post by:
Hi all,
combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |